﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 后台项目测试
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceStack.Redis.IRedisClient client = new ServiceStack.Redis.RedisClient("127.0.0.1", 6379);
            var flag = client.Set("sex", "男");
            var name = client.Get<string>("sex");
            flag= client.Set<object>("no", new { name = "lp", sex = 1 });
           var p= client.Get<object>("no");      
            //for (int i = 1; i < 6; i++)
            //{
            //    Console.WriteLine($"------第{i}次请求------");
            //    int result = DataSource.GetDataByDB(666);
            //    Console.WriteLine($"第{i}次请求获得的数据为：{result}");
            //}
            for (int i = 1; i < 6; i++)
            {
                Console.WriteLine($"------第{i}次请求------");
                int result = 0;
                //key的名字一定要确保请求的准确性 DataSource GetDataByDB 666缺一不可
                string key = "DataSource_GetDataByDB_666";

                //将需要执行的获取数据操作编写成委托传入方法(重点)
                //Func<int> func = new Func<int>(() => { return DataSource.GetDataByDB(666); });

                result = CacheHelper.GetCache(key, () => DataSource.GetDataByDB(666));
                Console.WriteLine($"第{i}次请求获得的数据为：{result}");
            }
            Console.ReadKey();
        }
    }
}
